package com.opensource.baodaoimpl.service;

import com.opensource.baodaoimpl.mapper.BidInfoMapper;
import com.opensource.baodaoimpl.mapper.ProductInfoMapper;
import com.opensource.baodaoimpl.mapper.UserMapper;
import com.opensource.datamodel.dto.IndexBaseInfoDto;
import com.opensource.datamodel.service.IndexBaseInfoService;
import io.swagger.models.auth.In;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;

/**
 * @author wzh
 * @date 2024/5/7
 * @apiNote
 */
@DubboService(interfaceClass = IndexBaseInfoService.class,version = "1.0")
//@Service
public class IndexBaseInfoServiceImpl implements IndexBaseInfoService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ProductInfoMapper productInfoMapper;
    @Autowired
    private BidInfoMapper bidInfoMapper;

    public IndexBaseInfoDto queryPlatIndexBaseInfo(){
        /*收益率平均值*/
        BigDecimal productAvgRate = productInfoMapper.selectProductAvgRate();
        /*累计成交金额*/
        BigDecimal bidSumMoney = bidInfoMapper.selectBidSumMoney();
        /*注册人数*/
        Integer registerUsers  = Math.toIntExact(userMapper.selectCount(null));
        return new IndexBaseInfoDto(productAvgRate, bidSumMoney, registerUsers);


    };



}
